<script type="text/javascript" src="<?= base_url() ?>scripts/purchasing.js"></script>
<br />
<div class="content_box left">
	<header>
		<div class="label">
			<img src="<?= base_url() ?>images/icons/information.png" alt=""><div>Requisition #<?= $requisition->rr_number ?></div>		
		</div>	
	</header>
	<section>
		<form>
			<table>
				<tr>
					<td>
						Requestor:
					</td>
					<td>
						<?= $requisition->requestor->name ?>
					</td>
				</tr>
				<tr>
					<td>
						Department:
					</td>
					<td>
						<?= $requisition->department ?>
					</td>
				</tr>
				<tr>
					<td>
						Date Requested:
					</td>
					<td>
						<?= $requisition->request_date ?>
					</td>
				</tr>					
				<tr>
					<td>
						Materials:
					</td>
					<td>
						<?= count($requisition->materials) ?>
					</td>
				</tr>		
				<tr>
					<td>
						Approved by:
					</td>
					<td>
						<?= $requisition->approver->name ?>
					</td>
				</tr>				
				<tr>
					<td>
						Canvassed by:
					</td>
					<td>
						<?= $requisition->canvasser->name ?>
					</td>
				</tr>
			</table>
		</form>
		<div style="padding:5px 5px 5px; float:right;">
			<a id="new_user_button" href="<?= base_url() ?>purchasing/createpo" class="btn"><span class="icon icon-ok"></span>Create PO</a>
			<a id="new_user_button" href="#new-user-popup" class="btn"><span class="icon icon-disk"></span>Save Draft</a>
		</div>		
	</section>
</div>
<div class="content_box right">
	<header>
		<div class="label">
			<img src="<?= base_url() ?>images/icons/information.png" alt=""><div>Materials</div>		
		</div>	
	</header>
	<section>
		<form>
			<table>
				<tr>
					<th style="width:25%;">Material</th>
					<th style="width:20%;">Supplier</th>
					<th style="width:10%;">Price</th>
					<th style="width:15%;"></th>
					<th style="width:12.5%;"><input type="checkbox" /> Approve</th>
					<th style="width:17.5%;"></th>
				</tr>
				<? foreach($requisition->materials as $material): ?>
				<tr>
					<td><?= $material->quantity . " " . $material->unit . " " . $material->name ?></td>
					<td><?= $material->supplier->name ?></td>
					<td><?= $material->sourcing->price ?></td>
					<td><a href="javascript: toggle_material_history('<?= $material->id ?>')">View Price History</a></td>
					<td><input type="checkbox" /> Approve</td>
					<td><a href="#">Change</a> - <a href="#">Remove</a></td>
				</tr>
				<tr class="material_history_<?= $material->id ?>" style="display:none;">
					<td></td>
					<td><?= $material->history1->supplier->name ?></td>
					<td><?= $material->history1->price ?></td>
					<td><?= $material->history1->date ?></td>
					<td></td>
					<td></td>
				</tr>
				<tr class="material_history_<?= $material->id ?>" style="display:none;">
					<td></td>
					<td><?= $material->history2->supplier->name ?></td>
					<td><?= $material->history2->price ?></td>
					<td><?= $material->history2->date ?></td>
					<td></td>
					<td></td>
				</tr>				
				<? endforeach; ?>
			</table>
		</form>
	</section>
</div>